package com.mr.service.api;

import com.b2c.common.utils.PageResult;
import com.mr.service.SpuBo;
import com.mr.service.pojo.Sku;
import com.mr.service.pojo.Spu;
import com.mr.service.pojo.SpuDetail;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("good")
public interface GoodsApi {

    @GetMapping("page")
    public PageResult<SpuBo> querySpuByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", defaultValue = "true") Boolean saleable,
            @RequestParam(value = "key") String key);
    /**
     * 根据spuid查询spu
     * @param spuId
     * @return
     */
    @GetMapping("spu/{id}")
    public Spu querySpuById(@PathVariable("id") Long spuId);

    /**
     * 根据id查询sku
     * @param skuId
     * @return
     */
    @GetMapping("sku/{id}")
    public  Sku querySkuById(@PathVariable("id") Long skuId);

    @GetMapping("/spu/detail/{spuId}")
    public SpuDetail queryDetail(@PathVariable("spuId") Long spuId);

    @GetMapping("skuList/{spuId}")
    public List<Sku> querySkus(@PathVariable("spuId") Long spuId);

    @PostMapping
    public Void saveGoods(@RequestBody SpuBo spuBo);

    @PutMapping
    public Void updataGoods(@RequestBody SpuBo spuBo);


    @DeleteMapping
    public  ResponseEntity delete(@RequestParam("id") Long id);
}
